<?php
class Web_Model_Log
{
	
	public static function write($content)
	{
		$year  = date('Y',Web_Model_Common::getNowTime());
		$month = date('Ym',Web_Model_Common::getNowTime());
		$day   = date('Ymd',Web_Model_Common::getNowTime());
		$forder = PROJECT_PATH . "Log/{$year}/{$month}";
		if(!file_exists($forder)){
    		mkdir($forder, 0777, TRUE);
    	}
		$fileName = PROJECT_PATH . "Log/{$year}/{$month}/normal{$day}.log";
		Eren_File::append($fileName, $content);
	}
	
	public static function start()
	{
		Eren_Timer::start();
		$content = "\r\n\r\n[Visit URL]" . Eren_Request_URL::getURL();
		$content .= "\r\n[FROM IP]" . Eren_Request_URL::getIP();
		$content .= "\r\n[Visite Time]" . Web_Model_Common::getFormatTime(Web_Model_Common::getNowTime()); 
		self::write($content);
	}
	
	public static function end()
	{
		$useTime = Eren_Timer::end();
		$content = "\r\n[Used Time]{$useTime}";
		self::write($content);
	}
}